package qiniu.voidcepc.voicepc.demos.web.localfunction.functionImpl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import qiniu.voidcepc.voicepc.demos.web.localfunction.FunctionCall;
import qiniu.voidcepc.voicepc.demos.web.vo.musicvo.KuWoMusicPlayer;

import java.io.IOException;


@Service
public class MusicFunction implements FunctionCall {

    @Autowired
    private KuWoMusicPlayer kuWoMusicPlayer;

    private String song_name;
    private String artist_name;
    private String description;



    /**
     * 暂停酷我音乐播放
     * @return 操作结果描述
     */
    public void pause() throws IOException {
        kuWoMusicPlayer.stopOrdisplaySing();
    }



    /**
     * 搜索酷我音乐
     * @param songName 歌曲名称
     * @param artistName 艺术家名称（可选）
     * @return 搜索结果描述
     */
    public void search(String songName, String artistName) {
        kuWoMusicPlayer.searchAndPlay(songName, artistName);
    }


    /**
     * 仅按歌曲名搜索
     * @param songName 歌曲名称
     * @return 搜索结果描述
     */
    public void search(String songName) {
        kuWoMusicPlayer.searchAndPlay(songName, "");
    }



    public String getJOSNVO() {
        // 生成符合阿里云LLM Function Calling格式的JSON描述
        return "{" +
                "\"name\": \"kuwo_music_controller\"," +
                "\"description\": \"酷我音乐控制功能，可用于播放、暂停、停止和搜索音乐\"," +
                "\"parameters\": {" +
                    "\"type\": \"object\"," +
                    "\"properties\": {" +
                        "\"action\": {" +
                            "\"type\": \"string\"," +
                            "\"description\": \"要执行的操作：play（播放）、pause（暂停）、stop（停止）、search（搜索）\"," +
                            "\"enum\": [\"play\", \"pause\", \"stop\", \"search\"]" +
                        "}," +
                        "\"song_name\": {" +
                            "\"type\": \"string\"," +
                            "\"description\": \"歌曲名称，用于play或search操作\"" +
                        "}," +
                        "\"artist_name\": {" +
                            "\"type\": \"string\"," +
                            "\"description\": \"艺术家名称，仅用于search操作\"" +
                        "}" +
                    "}," +
                    "\"required\": [\"action\"]" +
                "}" +
            "}";
    }

    // Getters and Setters
    public String getSong_name() {
        return song_name;
    }

    public void setSong_name(String song_name) {
        this.song_name = song_name;
    }

    public String getArtist_name() {
        return artist_name;
    }

    public void setArtist_name(String artist_name) {
        this.artist_name = artist_name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
